﻿namespace System.AutoUpdate.Library
{
    public class UpdateVersionInfo
    {
        public static UpdateFilenameBuilder FilenameBuilder
        {
            get;
            set;
        }

        public Version UpdateVersion
        {
            get;
            private set;
        }

        public DateTime UpdateReleaseDate
        {
            get;
            set;
        }

        public string Notes
        {
            get;
            set;
        }

        public UpdateFile File
        {
            get;
            set;
        }
        
        public UpdateVersionInfo (Version version, long versionSize, DateTime updateReleaseDate)
        {
            UpdateVersion = version;
            UpdateReleaseDate = updateReleaseDate;

            File = new UpdateFile
                   {
                       FileSize = versionSize
                   };
        }

        public override int GetHashCode()
        {
            return (UpdateVersion.GetHashCode() ^ UpdateReleaseDate.GetHashCode () ^ File.FileSize.GetHashCode ());
        }

        public override bool Equals(object obj)
        {
            if (obj.GetType () != GetType ())
            {
                return false;
            }

            UpdateVersionInfo infoObj = (UpdateVersionInfo) obj;

            return (UpdateVersion.Equals (infoObj.UpdateVersion) && UpdateReleaseDate.Equals (infoObj.UpdateReleaseDate) && File.FileSize.Equals (infoObj.File.FileSize));
        }
    }
}
